﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    DataTable dtb = new DataTable();
    string command;    

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.display();
        }
    }
    public void display()
    {
        command = "select top 8 TenXe,NgoaiThat,MaXe,NamSX,Image from ThongTinCoBan order by NgayNhap DESC";
        dtb = DataBase.GetDataTable(command);
        DataList1.DataSource = dtb;
        DataList1.DataBind();

        command = "select top 8 TenXe,NgoaiThat,MaXe,NamSX,DaBan,Image from ThongTinCoBan order by DaBan DESC";
        dtb = DataBase.GetDataTable(command);
        DataList2.DataSource = dtb;
        DataList2.DataBind();

    }

    protected void btn_ProductImage_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton btn = (ImageButton)sender;
        Response.Redirect("ProductDetail.aspx?Product=" + btn.CommandArgument);

    }

    protected void btn_CartAdd_Click(object sender, ImageClickEventArgs e)
    {
        ShoppingCart cart = (ShoppingCart)Session["ShoppingCart"];

        ImageButton btn = (ImageButton)sender;
        string maxe = btn.CommandArgument;
        cart.Add(maxe, 1);

        MasterPage master = (MasterPage)this.Master;
        master.RefreshShoppingCartInfo();
    }
}
